package jface.util;

import jface.data.Person;

import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;

public class PersonLabelProvider extends LabelProvider implements ITableLabelProvider {
		
	public String getText(Object element) {
		Person person = (Person) element;
		return person.getFirstName()+" "+person.getLastName()+" ("+person.getAge()+")";
	}
		
	public String getColumnText(Object element, int index) {
		Person person = (Person) element;
		switch (index) {
		case 0:
			return person.getFirstName();
		case 1:
			return person.getLastName();
		case 2:
			return person.getAge() + " Y";
		case 3:
			switch (person.getGender()) {
			case male:
				return "Man";
			case female:
				return "Woman";
			default:
				return "Unknown";
			}
		}
		return "?";
	}

	public Image getColumnImage(Object arg0, int arg1) {
		return null;
	}
	

}
